package com.example.qxfw.hbqx.mapper;

import com.baomidou.dynamic.datasource.annotation.DS;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.example.qxfw.common.entity.qx.HazeVisibilityForecast;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.Date;
import java.util.List;

@Mapper
@DS("service")
public interface HazeVisibilityForecastMapper extends BaseMapper<HazeVisibilityForecast> {
    /**
     *根据日期和站点id删除能见度预报
     * @param datechar 日期
     * @param stationid 站点id
     * @return
     */
    @Delete("DELETE FROM hazevisibility_forecast " +
            "WHERE DateChar = #{datechar} AND StationID = #{stationid}")
    int deleteByDateCharAndStationIdOfHazeVisibilityForecast(Date datechar, String stationid);

    /**
     *根据站点id，名称，日期，时效，能见度添加数据
     * @param stationid 站点id
     * @param stationname 站点名称
     * @param datechar 日期
     * @param ntimes 时效
     * @param hazevisibility 能见度范围
     * @return
     */
    @Insert("INSERT INTO HazeVisibilityForecast (stationid, stationname, datechar, ntimes, hazevisibility) " +
            "VALUES (#{stationid}, #{stationname}, #{datechar}, #{ntimes}, #{hazevisibility}) ")
    int insertByStationIDAndStationNameAndDateCharAndNTimesAndHazeVisibilityOfHazeVisibilityForecast(String stationid, String stationname, Date datechar, Date ntimes,Double hazevisibility);

    /**
     * 根据时间段和站点查询能见度报表时期，时效，能见度
     * @param stationid 站点id
     * @param datecharStart 起始时间
     * @param datecharEnd 终止时间
     * @return
     */
    @Select("SELECT datechar, ntimes, hazevisibility " +
            "FROM hazevisibility_forecast " +
            "WHERE stationid = #{stationid} AND datechar BETWEEN #{datecharStart} AND #{datecharEnd} ")
    List<HazeVisibilityForecast> selectByIdAndTimeframeOfHVF(String stationid, Date datecharStart, Date datecharEnd);

    /**
     * 通过站点id和日期查询能见度预报
     * @param stationid 站点id
     * @param datechar 日期
     * @return
     */
    @Select("SELECT datechar, ntimes, hazevisibility " +
            "FROM hazevisibility_forecast " +
            "WHERE stationid = #{datechar} AND datechar = #{datechar} ")
    List<HazeVisibilityForecast> selectByIdAndTimeOfHazeVisibilityForecast(String stationid, Date datechar);






}
